/**
 *====================================================
 * 文件名称: FinanceProductExpenseEntity.java
 * 修订记录：
 * No    日期				作者(操作:具体内容)
 * 1.    2015年11月11日			chenxy(创建:创建文件)
 *====================================================
 * 类描述：(说明未实现或其它不应生成javadoc的内容)
 */
package com.yuexunit.finance.project.entity;

import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.apache.commons.lang.StringUtils;

import com.yuexunit.finance.project.entity.lexicon.BillingMethodEnum;
import com.yuexunit.finance.project.entity.lexicon.ExpenseMethodEnum;
import com.yuexunit.finance.project.entity.lexicon.ExpenseScopeEnum;
import com.yuexunit.finance.project.entity.lexicon.ExpenseTypeEnum;
import com.yuexunit.finance.project.entity.lexicon.UnitEnum;

/**
 * @ClassName: FinanceProductExpenseEntity
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @author chenxy
 * @date 2015年11月11日 下午5:07:57
 */
@Entity
@Table(name = "FIN_FINANCE_PRODUCT_EXPENSE")
public class FinanceProductExpenseEntity {

	/** 费用ID */
	@Id
	@GeneratedValue
	@Column(name = "PRODUCT_EXPENSE_ID")
	private Long productExpenseId;

	/** 产品ID */
	@Column(name = "PRODUCT_ID")
	private Long productId;

	/** 费用名称 */
	@Column(name = "EXPENSE_NAME")
	private String expenseName;

	/** 费用类型 0:未知/1:提前罚息/2:延期罚息/3:费用项目 */
	@Column(name = "EXPENSE_TYPE")
	private ExpenseTypeEnum expenseType;

	/** 计算方式 0:未知/1:按自然箱/2:按标准箱/3:按货/4:其他 */
	@Column(name = "EXPENSE_METHOD")
	private ExpenseMethodEnum expenseMethod;

	/** 计价方式 0:未知/1:按单/2:按日 */
	@Column(name = "BILLING_METHOD")
	private BillingMethodEnum billingMethod;

	/** 是否比例 0:否/1:是(AMOUNT 则按百分比值计算) */
	@Column(name = "PROPORTION")
	private Boolean proportion;

	/** 费用阶段 0:未知/1:正常/2:超期 */
	@Column(name = "EXPENSE_SCOPE")
	private ExpenseScopeEnum expenseScope;

	/** 起始天数 */
	@Column(name = "START_DAY")
	private Integer startDay;

	/** 截止天数 */
	@Column(name = "END_DAY")
	private Integer endDay;

	/** 大宗商品类型ID */
	@Column(name = "BULKSTOCK_CATEGORY_ID")
	private Long bulkstockCategoryId;

	/** 类别名称 */
	@Column(name = "CATEGORY_NAME")
	private String categoryName;

	/** 大宗商品ID */
	@Column(name = "BULKSTOCK_INFO_ID")
	private Long bulkstockInfoId;

	/** 货名 */
	@Column(name = "BULKSTOCK_NAME")
	private String bulkstockName;

	/** 箱型 */
	@Column(name = "MODEL")
	private String model;

	/** 尺寸 */
	@Column(name = "DIMENSION")
	private String dimension;

	/** 计量单位 0:未知/1:吨/2:公斤/3:立方米 */
	@Column(name = "UNIT")
	private UnitEnum unit;

	/** 数值 */
	@Column(name = "AMOUNT")
	private BigDecimal amount;

	public Long getProductExpenseId() {
		return productExpenseId;
	}

	public void setProductExpenseId(Long productExpenseId) {
		this.productExpenseId = productExpenseId;
	}

	public Long getProductId() {
		return productId;
	}

	public void setProductId(Long productId) {
		this.productId = productId;
	}

	public String getExpenseName() {
		return expenseName;
	}

	public void setExpenseName(String expenseName) {
		this.expenseName = expenseName;
	}

	public ExpenseTypeEnum getExpenseType() {
		return expenseType;
	}

	public void setExpenseType(ExpenseTypeEnum expenseType) {
		this.expenseType = expenseType;
	}

	public ExpenseMethodEnum getExpenseMethod() {
		return expenseMethod;
	}

	public void setExpenseMethod(ExpenseMethodEnum expenseMethod) {
		this.expenseMethod = expenseMethod;
	}

	public Integer getStartDay() {
		return startDay;
	}

	public void setStartDay(Integer startDay) {
		this.startDay = startDay;
	}

	public Integer getEndDay() {
		return endDay;
	}

	public void setEndDay(Integer endDay) {
		this.endDay = endDay;
	}

	public Long getBulkstockCategoryId() {
		return bulkstockCategoryId;
	}

	public void setBulkstockCategoryId(Long bulkstockCategoryId) {
		this.bulkstockCategoryId = bulkstockCategoryId;
	}

	public String getCategoryName() {
		return categoryName;
	}

	public void setCategoryName(String categoryName) {
		this.categoryName = categoryName;
	}

	public Long getBulkstockInfoId() {
		return bulkstockInfoId;
	}

	public void setBulkstockInfoId(Long bulkstockInfoId) {
		this.bulkstockInfoId = bulkstockInfoId;
	}

	public String getBulkstockName() {
		return bulkstockName;
	}

	public void setBulkstockName(String bulkstockName) {
		this.bulkstockName = bulkstockName;
	}

	public String getModel() {
		return model;
	}

	public void setModel(String model) {
		this.model = model;
	}

	public String getDimension() {
		return dimension;
	}

	public void setDimension(String dimension) {
		this.dimension = dimension;
	}

	public UnitEnum getUnit() {
		return unit;
	}

	public void setUnit(UnitEnum unit) {
		this.unit = unit;
	}

	public BigDecimal getAmount() {
		return amount;
	}

	public void setAmount(BigDecimal amount) {
		this.amount = amount;
	}

	public BillingMethodEnum getBillingMethod() {
		return billingMethod;
	}

	public void setBillingMethod(BillingMethodEnum billingMethod) {
		this.billingMethod = billingMethod;
	}

	public Boolean getProportion() {
		return proportion;
	}

	public void setProportion(Boolean proportion) {
		this.proportion = proportion;
	}

	public ExpenseScopeEnum getExpenseScope() {
		return expenseScope;
	}

	public void setExpenseScope(ExpenseScopeEnum expenseScope) {
		this.expenseScope = expenseScope;
	}

	public String getBulkstockInfo() {
		StringBuffer sb = new StringBuffer();
		if (StringUtils.isNotBlank(this.categoryName)) {
			sb.append(this.categoryName);
		}
		if (StringUtils.isNotBlank(this.bulkstockName)) {
			sb.append(this.bulkstockName);
		}
		return sb.toString();
	}

	public String getAmountUnit() {
		StringBuffer sb = new StringBuffer();
		if (this.proportion) {
			sb.append("%");
		} else {
			sb.append("元");
		}
		if (BillingMethodEnum.DAYS == this.billingMethod) {
			sb.append("/天");
		}
		if (ExpenseMethodEnum.BULKSTOCK == this.expenseMethod) {
			if (UnitEnum.CUBIC_METRE == this.unit) {
				sb.append("/立方米");
			}
			if (UnitEnum.KG == this.unit) {
				sb.append("/公斤");
			}
			if (UnitEnum.TON == this.unit) {
				sb.append("/吨");
			}
		}
		if (ExpenseMethodEnum.NATURE == this.expenseMethod || ExpenseMethodEnum.STANDARD == this.expenseMethod) {
			sb.append("/箱");
		}
		return sb.toString();
	}

	public String getExpenseDescription() {
		StringBuffer sb = new StringBuffer();
		if (ExpenseMethodEnum.BULKSTOCK == this.expenseMethod) {
			if (StringUtils.isNotBlank(this.categoryName)) {
				sb.append(this.categoryName);
			}
			if (StringUtils.isNotBlank(this.bulkstockName)) {
				sb.append(this.bulkstockName);
			}
		} else if (ExpenseMethodEnum.NATURE == this.expenseMethod) {
			if (StringUtils.isNotBlank(this.model)) {
				sb.append(this.model);
			}
			if (StringUtils.isNotBlank(this.dimension)) {
				sb.append(this.dimension);
			}
		} else if (ExpenseMethodEnum.STANDARD == this.expenseMethod) {
			sb.append("按标准箱计算");
		}
		if (ExpenseScopeEnum.OVERDUE == this.expenseScope) {
			sb.append(" 超期费用");
		}
		if (BillingMethodEnum.DAYS == this.billingMethod) {
			sb.append(" 日期范围: ");
			if (this.startDay == null) {
				sb.append("第").append(0).append("~");
			} else {
				sb.append("第").append(this.startDay).append("~");
			}
			if (this.endDay == null) {
				sb.append("结束当天");
			} else {
				sb.append(this.endDay).append("天");
			}
		}
		return sb.toString();
	}

}
